import { IMessageBase } from "./IMessageBase";
type int = number;
//class MessageManager
// did
export class MessageManager {
  public regist(arg1: IMessageBase): void {
    this._object[arg1.getType()] = arg1;
    return;
  }

  public unRegist(arg1: int): void {
    if (this._object[arg1] == undefined) {
      return;
    }
    delete this._object[arg1];
    return;
  }

  public findMessage(arg1: int): IMessageBase | null {
    if (this._object[arg1] == undefined) {
      return null;
    }
    return this._object[arg1];
  }

  public createMessage(arg1: int): IMessageBase | null {
    if (this._object[arg1] == undefined) {
      return null;
    }
    return this._object[arg1].clone();
  }

  public static instance(): MessageManager {
    return MessageManager._instance;
  }

  private _object: Record<int, IMessageBase> = {};

  private static _instance: MessageManager = new MessageManager();
}
